#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/wait.h>
int main()
{
  printf("我是一个进程，我的pid是：%d\n",getpid());
  pid_t id=fork();
  if(id==0)//子进程
  {
  
      //execl("/usr/bin/pwd","pwd",NULL);
      //execl("/usr/bin/ls","ls","-a","-l",NULL);
      printf("我是一个进程，我的pid是：%d\n",getpid());
      //char* const argv_[]={
      //      (char*)"ls",
      //      (char*)"-a",
      //      (char*)"-l",
      //      NULL 
      //    }; 
      //execv("/user/bin/ls",argv_);
      char* const argv_[]={
        (char*)"top",
        NULL
      };
      execvp("top",argv_);
      //execlp("ls","ls","-l","-a",NULL);
      exit(1); 
  }
  int status=0;
  //printf("我是一个进程，我的pid是：%d\n",getpid());
  int ret= waitpid(id,&status,0);
  if(ret==id)
  {
    printf("父进程等待成功\n");
  }
  return 0;
}
